#!/bin/sh

abftool="./tool/abf-tool"

XML_DATAFILE="test/data/database.xml"
DAT_DATAFILE="test/data/database.dat"
ABF_DUMPFILE="test/data/abftest.dump"

TEMPFILE_1=`mktemp abf-dump.XXXX`
TEMPFILE_2=`mktemp abf-dump.XXXX`

echo "Testing abftest."
./test/abftest $TEMPFILE_1 > $TEMPFILE_2

echo "Testing abftest dump (no output == good)"
diff $TEMPFILE_2 $ABF_DUMPFILE

echo "Testing abf-tool (no output == good)"

$abftool dump $XML_DATAFILE > $TEMPFILE_1
$abftool dump $DAT_DATAFILE > $TEMPFILE_2
diff $TEMPFILE_1 $TEMPFILE_2

$abftool toxml $XML_DATAFILE $TEMPFILE_1
diff $XML_DATAFILE $TEMPFILE_1

$abftool todat $XML_DATAFILE $TEMPFILE_1
$abftool toxml $TEMPFILE_1 $TEMPFILE_2
diff $XML_DATAFILE $TEMPFILE_2

rm -f $TEMPFILE_1
rm -f $TEMPFILE_2

